Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
abortable-promise-cache
Advanced tools
Adds AbortController/AbortSignal semantics to a cache of promises. Each get
from the cache can optionally take an AbortSignal
object that lets that request be aborted.
Cached fill requests will be aborted and evicted from the cache if all the incoming requests for it are aborted before the promise settles.
If the fill request has already settled before all the requests for it have been aborted, it will stay in the cache.
$ npm install --save abortable-promise-cache
import AbortablePromiseCache from 'abortable-promise-cache'
import QuickLRU from 'quick-lru'
const cache = new AbortablePromiseCache({
// QuickLRU is a good backing cache to use, but you can use any
// cache as long as it supports `get`, `set`, `delete`, and `keys`.
cache: new QuickLRU({ maxSize: 1000 }),
// the `fill` callback will be called for a cache miss
async fill(requestData, abortSignal) {
// do some long-running thing
return longRunningThing(requestData, abortSignal)
}
})
// Make a cached request. The returned promise will abort with the given abort signal if
// there is not already a cached copy that has been resolved.
// Fill requests will be signaled to abort if all the requests for them
// so far have been aborted.
const aborter = new AbortController()
const result = await cache.get('some key', { ...anyStuff }, aborter.signal)
// deleting and clearing will abort any outstanding requests
cache.delete('some key')
cache.clear()
Parameters
args
object constructor args
Parameters
key
any cache key to use for this requestdata
any data passed as the first argument to the fill callbacksignal
AbortSignal? optional AbortSignal object that aborts the requestdelete the given entry from the cache. if it exists and its fill request has not yet settled, the fill will be signaled to abort.
Parameters
key
anyClear all requests from the cache. Aborts any that have not settled.
Returns number count of entries deleted
This package was written with funding from the NHGRI as part of the JBrowse project. If you use it in an academic project that you publish, please cite the most recent JBrowse paper, which will be linked from jbrowse.org.
MIT © Robert Buels
v1.5.0
FAQs
add AbortController support to a cache of async requests
The npm package abortable-promise-cache receives a total of 1,325 weekly downloads. As such, abortable-promise-cache popularity was classified as popular.
We found that abortable-promise-cache demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.